#include <stdio.h>
#include <stdint.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/eventfd.h>

int main()
{
    int efd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
    if(efd < 0)
    {
        perror("eventfd error");
        return -1;
    }

    uint64_t val = 1;
    write(efd, &val, sizeof(val));
    write(efd, &val, sizeof(val));
    write(efd, &val, sizeof(val));

    uint64_t res;
    read(efd, &res, sizeof(res));
    printf("%ld\n", res);

    close(efd);

    return 0;
}
// wenksen@wenksen-VMware-Virtual-Platform:~/mudou-concurrent-server/code/example$ md5sum eventfd.c
// 7596a1a020a1413f55687f9b91964a7f  eventfd.c
// wenksen@wenksen-VMware-Virtual-Platform:~/mudou-concurrent-server/code/example$ md5sum ttttt.c
// 7596a1a020a1413f55687f9b91964a7f  ttttt.c